package com.github.ltsopensource.example.springboot.utils;

import java.util.HashMap;
import java.util.Map;

/**
 * <b>类名称：</b>YmlHelper<br/>
 * <b>备注：</b><br/>
 *
 * @author kennylee <br />
 * @version 1.0.0 <br/>
 */
public class YmlHelper {

    /**
     * <p>由于yml文件构造的Map里面的key带有索引号，故此编写此方便遍历。</p>
     *
     * @return Map
     */
    public static <T> Map<String, T> getCMapper(Map<String, T> mapper) {
        Map<String, T> m = new HashMap<String, T>();
        for (Map.Entry<String, T> entry : mapper.entrySet()) {
            String oriKey = entry.getKey();
            String c = oriKey.contains(".") ? oriKey.substring(oriKey.indexOf(".") + 1) : oriKey;
            m.put(c, entry.getValue());
        }
        return m;
    }
}
